/*
 * @Author: dfh
 * @Date: 2024-10-15 10:13:14
 * @LastEditors: dfh
 * @Modified By: dfh
 * @describe: 
 */
import 'package:flutter/material.dart';
import 'package:flutter_pc_manager/app/modules/statistics_manager/views/turnover_widget.dart';
import 'package:flutter_pc_manager/app/modules/statistics_manager/views/user_widget.dart';
import 'package:get/get_state_manager/get_state_manager.dart';

import '../controllers/statistics_manager_controller.dart';

class StatisticsManagerView extends StatefulWidget {
  const StatisticsManagerView({super.key});

  @override
  State<StatisticsManagerView> createState() => _StatisticsManagerViewState();
}

class _StatisticsManagerViewState extends State<StatisticsManagerView> {

 final StatisticsManagerController _controller = StatisticsManagerController();

  @override
  void initState() {
    // _controller.fetchTurnoverData('2024-10-14', '2024-10-16');
    _controller.fetchUserData('2024-10-14', '2024-10-16');
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      margin: const EdgeInsets.all(10),
      child: Column(
        children: [
          Expanded(
            flex: 1,
            child: Row(
              children: [
                Expanded(
                  flex: 1,
                  child: Obx(()=>TurnoverWidget(dataX:_controller.turnoverX.value,dataY:_controller.turnoverY.value)),
                ),
                const SizedBox(
                  width: 20,
                ),
                Expanded(
                  flex: 1,
                  child: Obx(()=>UserWidget(dataX: _controller.userX.value, dataY: _controller.totalUserY.value, data2Y: _controller.newUserY.value)),
                ),
              ],
            ),
          ),
          const SizedBox(
            height: 20,
          ),
          Expanded(
            flex: 1,
            child: Row(
              children: [
                Expanded(
                  flex: 1,
                  child: Container(
                    color: Colors.red,
                  ),
                ),
                const SizedBox(
                  width: 20,
                ),
                Expanded(
                  flex: 1,
                  child: Container(
                    color: Colors.red,
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }
}
